//
//  AppDelegate.m
//  Activity
//
//  Created by its on 15/5/7.
//  Copyright (c) 2015年 coco. All rights reserved.
//

#import "AppDelegate.h"
#import "CCRPhoneViewController.h"
#import <AVOSCloud/AVOSCloud.h>
#import "CCRPhoneViewModel.h"
#import "CCLoginViewController.h"
#import "CCAPublicViewController.h"
#import "CCRPhoneViewController.h"
#import "CCAcitivityModel.h"
#import "CCAPublicModel.h"
#import "CCAListViewController.h"
#import "CCAListViewModel.h"
#import "CCAListViewModel.h"
#import "CCADetailViewController.h"
#import "CCDetailViewModel.h"
//#import "CCNaviViewController.h"
#import "CCDevice.h"
#import "CCCommentModel.h"
#import "CCCommentViewController.h"
#import "CCAlertViewController.h"
#import "CCAlertViewModel.h"
#import <SPInteractivePopNavigationController/SPInteractivePopNavigationController.h>
#define AVOSCloudAppID  @"vgm655n2kxn4knm0t6iqbvszc9dew2q50fz0v2ma5oln5s1e"
#define AVOSCloudAppKey @"q33a2gzrwex6o5pwg0khmee947xqyunxjuoudseqd1nw2jrw"
@interface AppDelegate ()
@property(nonatomic, strong) CCAPublicModel *viewModel;
@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [AVOSCloud setApplicationId:AVOSCloudAppID clientKey:AVOSCloudAppKey];
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  self.window.backgroundColor = [UIColor whiteColor];
//  [self test];
  [self testActivity];
  [self.window makeKeyAndVisible];
  return YES;
}

- (void) getNavigatonBarFrame {
  UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:nil];
  naviwidth = navi.navigationBar.frame.size.width;
  naviheight = navi.navigationBar.frame.size.height;
}
- (void)applicationWillResignActive:(UIApplication *)application {
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
}

- (void)applicationWillTerminate:(UIApplication *)application {
}

- (void) test {
  [AVUser logInWithMobilePhoneNumberInBackground:@"18680306621" password:@"123456" block:^(AVUser *user, NSError *error) {
    AVStatusQuery *query = [AVStatus inboxQuery:@"private"];
//    query.owner = [AVUser currentUser];
//    [AVStatus getUnreadStatusesCountWithType:@"private" andCallback:^(NSInteger number, NSError *error) {
//      
//    }];
  }];
}
- (void) testActivity {
  UITabBarController *barController = [[UITabBarController alloc] init];
  barController.tabBar.translucent = NO;
  CCAcitivityModel *activity = [[CCAcitivityModel alloc] init];
  CCAListViewModel *viewModel = [[CCAListViewModel alloc] initWithModel:activity];
  CCAListViewController *listViewController = [[CCAListViewController alloc] initWithViewModel:viewModel];
  listViewController.hidesBottomBarWhenPushed = YES;
  SPInteractivePopNavigationController *navi = [[SPInteractivePopNavigationController alloc] initWithRootViewController:listViewController];
  navi.navigationBar.translucent = NO;
  navi.navigationBar.barTintColor = RGB(46, 169, 56, 1);
  navi.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
  UIImage *homeImage1 = IMAGE(@"bar_home_normal");
  UIImage *homeImage2 = IMAGE(@"bar_home_press");
  homeImage1 = [homeImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  homeImage2 = [homeImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  navi.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"活动" image:homeImage1 selectedImage:homeImage2];
  [navi.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(46, 169, 56, 1)} forState:UIControlStateNormal];
  CCAlertViewModel *viewModel2 = [[CCAlertViewModel alloc] init];
  CCAlertViewController *alertViewController = [[CCAlertViewController alloc] initWithViewModel:viewModel2];
  SPInteractivePopNavigationController *navi2 = [[SPInteractivePopNavigationController alloc] initWithRootViewController: alertViewController];
  navi2.navigationBar.translucent = NO;
  navi2.navigationBar.barTintColor = RGB(46, 169, 56, 1);
  navi2.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
  UIImage *homeImage3 = IMAGE(@"bar_home_normal");
  UIImage *homeImage4 = IMAGE(@"bar_home_press");
  homeImage1 = [homeImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  homeImage2 = [homeImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  navi2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"提醒" image:homeImage3 selectedImage:homeImage4];
  [navi2.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(46, 169, 56, 1)} forState:UIControlStateNormal];
  
  barController.viewControllers = @[navi, navi2];
  self.window.rootViewController = barController;
  [CCRouter setNavigationController:navi];
}

@end
